
<?php
include '../variables/varConector.php';

if ($_REQUEST["opc"] == '') {


       include '../funciones/funciones.php';
       echo "<div style=\"padding-left: 80px; padding-right: 80px; padding-top: 150px;\" align=\"center\">";
       cadenaFondoAzul("Insertar C&eacute;dula");
       echo "</div>";
?>

       <div style="padding-left: 100px; padding-right: 100px; padding-top: 5px;" align="center">
              <div style="width: 300px;">
              <form action="?p=socio/eliminarSocio&opc=busco" method="POST">
                     <table>
                            <tr>
                                   <td align="left" style="width: 100px;">C&eacute;dula</td>
                                   <td>
                                          <input name="cedula" id="cedula" type="text" style="width: 150px;">
                                   </td>
                            </tr>
                            <tr>
                                   <td colspan="2" align="center">
                                          <input type="submit" value="Buscar">
                                   </td>
                            </tr>
                     </table>
              </form>


       </div>
</div>

<?php
              } else
              if ($_REQUEST["opc"] == 'busco') {

                     include '../funciones/funciones.php';

                     foreach ($_REQUEST AS $clave => $valor) {
                            $$clave = $valor;
                     }

                     $conector = mysql_connect(HOST, USUARIO, PASSWORD);
                     mysql_select_db(BD, $conector);
                     $sql = "SELECT * FROM socio WHERE cedula = '$cedula' AND activo = 1";
                     $resultado = mysql_query($sql, $conector);
                     mysql_close($conector);

                     if (mysql_num_rows($resultado) == '1') {
                            $linea = mysql_fetch_row($resultado);
?>

                            <div style="padding-left: 100px; padding-right: 100px; padding-top: 150px;" align="center">
                                   <div style="width: 300px;">


                                          <form action="?p=socio/eliminarSocio&opc=modifico" method="POST">
                                                 <table>
                                                        <tr>
                                                               <td align="left" style="width: 100px;">Nombre</td>
                                                               <td>
                                                                      <input type="text" value="<?php echo $linea["2"]; ?>" style="width: 150px;" disabled="true">
                                                               </td>
                                                        </tr>
                                                        <tr>
                                                               <td align="left" style="width: 100px;">C&eacute;dula</td>
                                                               <td>
                                                                      <input type="text" value="<?php echo $linea["1"]; ?>" style="width: 150px;" disabled="true">
                                                               </td>
                                                        </tr>
                                                        <tr>
                                                               <td align="left" style="width: 100px;">Tel&eacute;fono</td>
                                                               <td>
                                                                      <input type="text" value="<?php echo $linea["3"]; ?>" style="width: 150px;" disabled="true">
                                                               </td>
                                                        </tr>
                                                        <tr>
                                                               <td align="left" style="width: 100px;">Status</td>
                                                               <td><select style="width: 150px;" disabled="true">
                                                                             <option value="0" <?php if ($linea["4"] == '0') { echo "selected"; } ?>>Ordinario</option>
                                                                             <option value="1" <?php if ($linea["4"] == '1') { echo "selected"; } ?>>Directivo</option>
                                                                      </select>
                                                               </td>
                                                        </tr>
                                                        <tr>
                                                               <td colspan="2" align="center">
                                                                      <input type="submit" value="Eliminar">
                                                               </td>
                                                        </tr>
                                                 </table>
                                                 <input type="hidden" name="nombre" value="<?php echo $linea["2"]; ?>">
                                                 <input type="hidden" name="cedula" value="<?php echo $linea["1"]; ?>">
                                                 <input type="hidden" name="telefono" value="<?php echo $linea["3"]; ?>">
                                                 <input type="hidden" name="status" value="<?php echo $linea["4"]; ?>">
                                          </form>


                                   </div>
                            </div>

<?php
                     }else{
                           echo "<div style=\"padding-left: 100px; padding-right: 100px; padding-top: 150px;\" align=\"center\">";
                           cadenaFondoAzul("No se encontro algun Socio con esa C&eacute;dula");
                           echo "</div>";
                     }
              } else
              if ($_REQUEST["opc"] == 'modifico') {
                     include '../funciones/funciones.php';

                     foreach ($_REQUEST AS $clave => $valor) {
                            $$clave = $valor;
                     }

                     $conector = mysql_connect(HOST, USUARIO, PASSWORD);
                     mysql_select_db(BD, $conector);
                     $sql = "UPDATE socio SET activo = 0 WHERE cedula = '$cedula'";
                     $resultado = mysql_query($sql, $conector);
                     $linea = @mysql_fetch_row($resultado);

                     print (mysql_error());
                     mysql_close($conector);


                    echo "<div style=\"padding-left: 100px; padding-right: 100px; padding-top: 150px;\" align=\"center\">";
                           cadenaFondoAzul("Se elimino exitosamente el Socio");
                    echo "</div>";


              }
?>